package com.hsh.service.impl;

import com.hsh.dao.UserDao;
import com.hsh.dao.impl.UserDaoImpl;
import com.hsh.pojo.Page;
import com.hsh.pojo.User;
import com.hsh.service.UserService;

import java.util.List;

/**
 * @author xrkhy
 * @date 2025/6/27 9:38
 * @description
 */
public class UserServiceImpl implements UserService {
    /**
     * 登录
     * @param user
     * @return
     */
    @Override
    public User login(User user) {
        return new UserDaoImpl().login(user);
    }

    @Override
    public int register(User user) {
        return new UserDaoImpl().register(user);
    }

    @Override
    public Page<User> pageQuery(Page<User> page) {
        page.setStartIndex();
        UserDao userDao = new UserDaoImpl();
        List<User> list = userDao.pageQuery(page);

        int totalCount =userDao.queryTotalCount(page);
        page.setResultList(list);
        page.setTotalCount(totalCount);
        return page;
    }

    @Override
    public int updateUser(User user) {
        return new UserDaoImpl().updateUser(user);
    }

    @Override
    public int deleteUser(int id) {
        return new UserDaoImpl().deleteUser(id);
    }
}
